package org.zlex.chapter03;

import util.SkyLogger;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.security.Timestamp;
import java.security.cert.CertPath;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.util.Date;

/**
 * @author : wushikai
 * <p>
 * date : 2021-04-22
 */
public class TimeStampDemo {

    static SkyLogger log = new SkyLogger();

    public  static void test ( ) throws CertificateException, FileNotFoundException {

        String  filePath = "d:\\CertTrustChain.cer";  //如果你的证书不可用, 就会报异常

        File file = new File(filePath);

        log.info("file.exists() => " + file.exists());

        CertificateFactory cf = CertificateFactory.getInstance("x509"); // 指定整数类型是 x509

        CertPath certPath = cf.generateCertPath(new FileInputStream(filePath));


        Timestamp timestamp = new Timestamp(new Date(), certPath);


        log.info("timestamp => " + timestamp);



    }


    public static void main(String[] args) throws CertificateException, FileNotFoundException {

        test();

    }

}
